package com.gjy.kafka.java.util;

/**
 * @author gjy
 * @version 1.0
 * @since 2024-06-25 09:32:15
 */
public class CommonUtil {

    /**
     * 小驼峰转为大写+下划线，如settleStatus -> SETTLE_STATUS
     *
     * @param input 小驼峰字符串
     * @return 大写字符串
     */
    public static String convertCamelToUpperCase(String input) {
        StringBuilder result = new StringBuilder();

        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);

            if (Character.isUpperCase(c)) {
                result.append("_").append(Character.toUpperCase(c));
            } else {
                result.append(Character.toUpperCase(c));
            }
        }

        return result.toString();
    }

}
